package com.qzsoft.zhjd.exp.modules.laboratorystatistics.controller;

import com.qzsoft.jeemis.common.utils.Result;
import com.qzsoft.zhjd.common.utils.ResultUtils;
import com.qzsoft.zhjd.exp.modules.laboratorystatistics.service.LaboratoryStatisticsService;
import com.qzsoft.zhjd.exp.modules.laboratorystatistics.utils.LaboratoryStatisticsEnum;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/*
 * @Author zhaij
 * @Description //实验室设备统计
 * @Date 10:16 2021\12\2 0002
 * @Param
 * @return
 **/
@RestController
@RequestMapping("/api/laboratorydatastatistics")
public class LaboratoryStatisticsController {

    @Autowired
    private LaboratoryStatisticsService statisticsService;
    /*
     * @Author zhaij
     * @Description //实验室设备术图
     * @Date 10:17 2021\12\2 0002
     * @Param [map]
     * @return com.qzsoft.jeemis.common.utils.Result<java.util.Map<java.lang.String,java.lang.Object>>
     **/
    @RequiresPermissions({"api:laboratorydatastatistics:statisticsByPenetration","api:laboratorymarshell:marshall"})
    @GetMapping("/datastatistics")
    public Result<Map<String,Object>> datastatistics(@RequestParam(required = false) Map<String,Object> map){
        Map<String,Object> result = statisticsService.datastatistics(map);
        return ResultUtils.ok(result);
    }

    /*
     * @Author zhaij
     * @Description //实验室设备合格占比饼图
     * @Date 10:17 2021\12\2 0002
     * @Param [map]
     * @return com.qzsoft.jeemis.common.utils.Result<java.util.Map<java.lang.String,java.lang.Object>>
     **/
    @GetMapping("/datapies")
    public Result<List<Map<String,Object>>> datapies(@RequestParam Map<String,Object> map){
        List<Map<String,Object>> result = statisticsService.datapies(map);
        return ResultUtils.ok(result);
    }

    /*
     * @Author zhaij
     * @Description //实验室设备合格率柱图
     * @Date 10:17 2021\12\2 0002
     * @Param [map]
     * @return com.qzsoft.jeemis.common.utils.Result<java.util.Map<java.lang.String,java.lang.Object>>
     **/
    @RequiresPermissions({"api:laboratorydatastatistics:statisticsByPenetration","api:laboratorymarshell:marshall"})
    @GetMapping("/dataQualifiedCol")
    public Result<Map<String,Object>> dataQualifiedCol(@RequestParam Map<String,Object> map){
        Map<String,Object> result = statisticsService.dataQualifiedCol(map);
        return ResultUtils.ok(result);
    }

    /*
     * @Author zhaij
     * @Description //不同类型实验数据统计
     * @Date 10:17 2021\12\2 0002
     * @Param [map]
     * @return com.qzsoft.jeemis.common.utils.Result<java.util.Map<java.lang.String,java.lang.Object>>
     **/
    @RequiresPermissions("api:laboratorydatastatistics:statisticsByPenetration")
    @GetMapping("/dataStatisticsBySoft")
    public Result<List<Map<String,Object>>> dataStatisticsByType(@RequestParam Map<String,Object> map){
        map.put("category", LaboratoryStatisticsEnum.SOFT_POINT.getCode());
        List<Map<String,Object>> result = statisticsService.dataStatisticsByType(map);
        return ResultUtils.ok(result);
    }

    @RequiresPermissions("api:laboratorydatastatistics:statisticsByPenetration")
    @GetMapping("/dataStatisticsByDuctility")
    public Result<List<Map<String,Object>>> dataStatisticsByPen(@RequestParam Map<String,Object> map){
        map.put("category", LaboratoryStatisticsEnum.DUCTILITY.getCode());
        List<Map<String,Object>> result = statisticsService.dataStatisticsByType(map);
        return ResultUtils.ok(result);
    }


    @RequiresPermissions("api:laboratorydatastatistics:statisticsByPenetration")
    @GetMapping("/dataStatisticsByPenetration")
    public Result<List<Map<String,Object>>> dataStatisticsByPenetration(@RequestParam Map<String,Object> map){
        map.put("category", LaboratoryStatisticsEnum.PENETRATION.getCode());
        List<Map<String,Object>> result = statisticsService.dataStatisticsByType(map);
        return ResultUtils.ok(result);
    }

    @RequiresPermissions("api:laboratorymarshell:marshall")
    @GetMapping("/dataStatisticsByStability")
    public Result<List<Map<String,Object>>> dataStatisticsByStability(@RequestParam Map<String,Object> map){
        map.put("category", LaboratoryStatisticsEnum.MARSHALL.getCode());
        List<Map<String,Object>> result = statisticsService.dataStatisticsByType(map);
        return ResultUtils.ok(result);
    }
    /*
     * @Author zhaij
     * @Description //燃烧炉实验数据
     * @Date 11:36 2021\12\4 0004
     * @Param [map]
     * @return com.qzsoft.jeemis.common.utils.Result<java.util.List<java.util.Map<java.lang.String,java.lang.Object>>>
     **/
    @RequiresPermissions("api:laboratorymarshell:marshall")
    @GetMapping("/dataFurnace")
    public Result<List<Map<String,Object>>> dataFurnace(@RequestParam Map<String,Object> map){
        map.put("category", LaboratoryStatisticsEnum.FURNACE.getCode());
        map.remove("deptId");
        List<Map<String,Object>> result = statisticsService.dataStatisticsByType(map);
        return ResultUtils.ok(result);
    }

}
